<?php

namespace app\adminapi\controller\v1\report;

use app\adminapi\controller\AuthController;
use app\services\report\ReportServices;
use app\services\user\UserServices;
use think\facade\App;
use think\Request;

class Report extends AuthController
{

    /**
     * user constructor.
     * @param App $app
     * @param ReportServices $services
     */
    public function __construct(App $app, ReportServices $services)
    {
        parent::__construct($app);
        $this->services = $services;
    }

    public function report()
    {
        $get = $this->request->getMore([
            ['page', 1],
            ['pageNum', 10],
        ]);
        $list = $this->services->getSumList([], '*', $get['page'], $get['pageNum']);
        $count = $this->services->getSumCount([]);

        return app('json')->success(compact('list', 'count'));

    }

    public function agentReport(UserServices $userServices)
    {
        $get = $this->request->getMore([
            ['date', ''],
        ]);
        $date = [];
        if (!empty($get['date'])) {
            $dateArr = explode('-', $get['date']);
            $date['start'] = strtotime($dateArr[0]);
            $date['end'] = strtotime($dateArr[1]);
        }
        return app('json')->success($userServices->getAgentUser($date));
    }


}